package com.gofaraway.service.student.leetCodeV2;

/**
 * @author ChenPeng
 * @Date 2024/11/29 11:36
 */
public class 上台阶问题 {

    private static int total = 1;

    /**
     * 每次可上1个台阶获2个台阶，问到第n个台阶有多少种方式
     */
    public static int fun(int n) {
        if (n == 1) {
            return 1;
        } else if (n == 2) {
            return 2;
        } else {
            return fun(n - 1) + fun(n - 2);
        }
    }

    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        fun(10);
        System.out.println("n=10时运行时间："+(System.currentTimeMillis() - start));
        start = System.currentTimeMillis();
        fun(30);
        System.out.println("n=30时运行时间："+(System.currentTimeMillis() - start));
        start = System.currentTimeMillis();
        fun(40);
        System.out.println("n=40时运行时间："+(System.currentTimeMillis() - start));
    }

}
